package com.ostrich.module_main.viewholder

import android.animation.ObjectAnimator
import android.view.View
import android.widget.ImageView
import com.ostrich.module_main.R
import com.ostrich.module_main.bean.CustomBean
import com.zhpan.bannerview.holder.ViewHolder

/**
 * @Author : yaotianxue
 * @Time : On 2023/10/25 10:10
 * @Description : CustomPagerViewHolder 轮播图viewholder
 */
class CustomPagerViewHolder: ViewHolder<CustomBean> {
    override fun getLayoutId(): Int {
       return R.layout.main_item_custom_view
    }

    override fun onBind(itemView: View?, data: CustomBean?, position: Int, size: Int) {
        val imageView = itemView?.findViewById<ImageView>(R.id.banner_image)
        data?.let {
            imageView?.setImageResource(it.imageRes)
        }
        //动画效果
        val animator = ObjectAnimator.ofFloat(imageView, "alpha", 0f, 1f)
        animator.duration = 1500
        animator.start()
    }
}